package com.shareyi.baseproject.kernel.adapter.spi;

import com.alibaba.fastjson.JSON;
import com.shareyi.baseproject.kernel.common.spi.ObjectSerialization;

import java.util.List;

/**
 * 默认的对象序列化工具
 *
 * @author david
 * @date 2021-08-31
 */
public class DefaultObjectSerialization implements ObjectSerialization {

    @Override
    public String toJSONString(Object object) {
        return JSON.toJSONString(object);
    }

    @Override
    public <T> T parseObject(String json, Class<T> clazz) {
        return JSON.parseObject(json, clazz);
    }

    @Override
    public <T> List<T> parseArray(String json, Class<T> clazz) {
        return JSON.parseArray(json, clazz);
    }
}
